React = require('react')
{View,Text,Image,StyleSheet,ScrollView,TouchableHighlight,TouchableOpacity} = require('react-native')
{View,Text,Image,StyleSheet} = require('react-native')
Toast = require('antd-mobile/lib/toast')
_ = require('underscore')
moment = require('moment') 

Pilot = React.createClass
  getWorkClass:(item)->
    switch item
      when '1' then '全程'
      when '2' then '移泊'
      when '3' then '搭客'
      else ''
  _processTime:(time)->
    t = moment(time)
    if t.isValid()
      t.format('DD/HHmm')
    else
      ""
  render:->
    item = @props.item
    <View key={item.VCPILOTNAME} style={styles.card}>
      <View style={styles.row}>
        <Text style={styles.textContent}>{item.VCPILOTNAME}</Text>
      </View>
      <View style={styles.row}>
        <View style={styles.cell}>
          <Text style={styles.text}>工作类型</Text>
          <Text style={styles.textContent}>{@getWorkClass item.CHWORKCLASS}</Text>
        </View>
        <View style={styles.cell}>
          <Text style={styles.text}>档次</Text>
          <Text style={styles.textContent}>{item.DC}</Text>
        </View>
      </View>
      <View style={styles.row}>
        <View style={styles.cell}>
          <Text style={styles.text}>电话2</Text>
          <Text style={styles.textContent}>{item.VCTELEPHONE2}</Text>
        </View>
        <View style={styles.cell}>
          <Text>手机1：</Text>
          <Text style={styles.textContent}>{item.VCMOBILENUMBER1}</Text>
        </View>
      </View>
      <View style={styles.row}>
        <View style={styles.cell}>
          <Text>手机2：</Text>
          <Text style={styles.textContent}>{item.VCMOBILENUMBER2}</Text>
        </View>
        <View style={styles.cell}>
          <Text style={styles.text}>预约时间</Text>
          <Text style={styles.textContent}>{@_processTime item.DTBESPEAKTIME}</Text>
        </View>
      </View>
      <View style={styles.row}>
        <View style={styles.cell}>
          <Text style={styles.text}>接到时间</Text>
          <Text style={styles.textContent}>{@_processTime item.DTMEETTIME}</Text>
        </View>
        <View style={styles.cell}>
          <Text style={styles.text}>港车时间</Text>
          <Text style={styles.textContent}>{@_processTime item.DTPORTCARTIME}</Text>
        </View>
      </View>
      <View style={styles.lastRow}>
        <View style={styles.cell}>
          <Text style={styles.text}>后接到时间</Text>
          <Text style={styles.textContent}>{@_processTime item.DTLATERMEETTIME}</Text>
        </View>
        <View style={styles.cell}>
          <Text>车次：</Text>
          <Text style={styles.textContent}>{item.NM_PORTCARNO}</Text>
        </View>
      </View>
    </View>



styles = StyleSheet.create
  card:
    borderRadius:10
    borderWidth:1
    borderStyle:'solid'
    borderColor:'#CCCCCC'
    flexDirection:'column'
    backgroundColor:'#ffffff'
    marginLeft:5
    marginRight:5
    marginBottom:10
  row:
    flexDirection:'row'
    borderBottomWidth:0.5
    borderStyle:'solid'
    borderBottomColor:'#CCCCCC'
    backgroundColor:'#ffffff'
    padding:10
    marginLeft:10
    marginRight:10
  lastRow:
    flexDirection:'row'
    padding:10
    marginLeft:10
    marginRight:10
    overflow:'visible'
  cell:
    flex:1
    flexDirection:'row'
  text:
    flex:1
  textContent:
    flex:1
    color:'black'
    # fontWeight:'bold'
# styles = StyleSheet.create
#   row:
#     flexDirection:'row'
#     borderWidth:0.3
#     borderStyle:'solid'
#     borderColor:'#CCCCCC'
#     backgroundColor:'#ffffff'
#     padding:10
#     marginLeft:10
#     marginRight:10
#   cell:
#     flex:1
#     flexDirection:'row'
#   text:
#     flex:1
#   textContent:
#     flex:1
#     fontWeight:'bold'


module.exports = Pilot
